<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Controller for managing forms.
 * @package cms-forms/conrollers
 * @category Controller
 * 
 * @author Mark Angelo Angulo
 * @copyright (c) 2014
 */
class Form extends CMS_Controller {

    /**
     *  Constructor method.
     */
    function __construct()
    {
        parent::__construct();
        
        $this->load->model('cms-countries/country_model');
        
        $this->load->helper('generator');
        
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        
    }

    /**
     * Default method called when nothing is specified.
     * Displays basic forms.
     * @access public
     */
    public function index()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Basic Form');

        // build template
        $this->template
                ->title('Form')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
//                ->set_partial('footer', 'layouts/admin/footer')
                ->build('index', $data);
        
    }
    
    public function basic()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Basic');

        // build template
        $this->template
                ->title('Basic Form')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('basic', $data);
    }
    
    public function advance()
    {
        // active navigation
        $data['navigation'] = 'forms';
        
        // generate captcha
        $captcha = generate_captcha('6', '900', '300', '100');
        $data['captcha_image'] = $captcha['image'];
    
        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Advance');

        // build template
        $this->template
                ->title('Advance Form')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('advance', $data);
    }
    
    public function advance_validation()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Advance Validation');

        // build template
        $this->template
                ->title('Advance Form Validation')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('advance_validation', $data);
    }
    
    public function masked()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Masked Inputs');

        // build template
        $this->template
                ->title('Masked Inputs')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('masked', $data);
    }
    
    public function wizard()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Wizard');

        // build template
        $this->template
                ->title('Form Wizard')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('wizard', $data);
    }
    
    public function advance_wizard()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Advance Form Wizard');

        // build template
        $this->template
                ->title('Advance Form Wizard')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('advance_wizard', $data);
    }
    
    public function settings()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Settings');

        // build template
        $this->template
                ->title('Form Settings')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('settings', $data);
    }
    
    public function custom()
    {
        // active navigation
        $data['navigation'] = 'forms';

        // build breadcrumb
        $this->breadcrumb->clear();
        $this->breadcrumb->add_crumb('Forms');
        $this->breadcrumb->add_crumb('Custom');

        // countries
        $data['countries'] = $this->country_model->get_all();
        
        // build template
        $this->template
                ->title('Custom Form')
                ->set_layout('main')
                ->set_partial('navigation', 'layouts/navigation')
                ->build('custom', $data);
    }
    
    public function validate()
    {
        $this->form_validation
                ->set_rules('datetimepicker', 'datetimepicker', 'required|valid_slash_datetime');

        if ( $this->form_validation->run() == FALSE )
        {
            echo 'ayaw';
        } else
        {
            echo 'pwede';
        }
    }
}

/* End of file form.php */
/* Location: ./application/modules/cms-forms/controllers/form.php */